package com.nxk.modules.content.web;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.nxk.modules.content.entity.ConMessage;
import com.nxk.modules.content.entity.ConNews;
import com.nxk.modules.content.service.ConMessageService;
import com.nxk.modules.content.service.ConNewsService;
import com.nxk.modules.core.entity.SysUser;
import com.nxk.modules.core.service.SysColunmService;
import com.nxk.modules.core.service.SysUserService;
import com.nxk.modules.exception.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

@RestController
@RequestMapping("/a/content/index")
public class IndexCountController {


    @Autowired
    private SysColunmService sysColunmService;

    @Autowired
    private SysUserService sysUserService;

    @Autowired
    private ConNewsService conNewsService;

    @Autowired
    private ConMessageService conMessageService;


    @PostMapping("/count")
    public ResultEntity count(){
        int sysColunmCount = sysColunmService.count();

        QueryWrapper<SysUser> queryWrapper=new QueryWrapper<>();
        queryWrapper.in("status","1","2");
        int sysUserCount = sysUserService.count(queryWrapper);

        QueryWrapper<ConNews> queryWrapper2=new QueryWrapper<>();
        queryWrapper2.in("status","1","2");
        int sysNewsCount = conNewsService.count(queryWrapper2);

        QueryWrapper<ConMessage> queryWrapper3=new QueryWrapper<>();
        queryWrapper3.in("status","1","2");
        int sysMessageCount = conMessageService.count(queryWrapper3);

        return ResultEntity.success(Arrays.asList(sysColunmCount,sysUserCount,sysNewsCount,sysMessageCount));
    }

}

